##
##This is Makefile for DAMA NCS software.
##This file could help you to generate ncs_servd and ncs_clientd
##executable file,when you use "make" command.
##
##Copyright (C) 2016-1 andisat <www.andisat.com>
##
##Author: andisat
##Date: 2016-1
##
##
## The source codes and their head-files dirs
SRCDIR = .
INCLUDES = -I$(SRCDIR) -I$(SRCDIR)/libdao/include \
           -I$(SRCDIR)/libevent-2.0.22-stable/include 

## The compile options
CC = gcc
CFLAGS = -Os -g -std=c99

## The link dir and library options
#LDFALGS = -L$(SRCDIR)/libdao/lib 
LIBS = -lncsdao -levent

ncs_serv_main = ncs_serv.c
ncs_client_main = ncs_client.c

Serv_exclude_objects = $(patsubst %.c,%.o,$(ncs_client_main))
Client_exclude_objects = $(patsubst %.c,%.o,$(ncs_serv_main))

Objects = $(patsubst %.c,%.o,$(wildcard *.c))
Objects_serv = $(filter-out $(Serv_exclude_objects),$(Objects))
Objects_client = $(filter-out $(Client_exclude_objects),$(Objects))

all : ncs_servd ncs_clientd

ncs_servd : $(Objects_serv)
	$(CC) $(CFLAGS) $(INCLUDES) $^ -o $@ $(LDFALGS) $(LIBS)

ncs_clientd : $(Objects_client)
	$(CC) $(CFLAGS) $(INCLUDES) $^ -o $@ $(LDFALGS) $(LIBS)
	
.c.o:
	$(CC) $(CFLAGS) $(INCLUDES) -c $<


.PHONY : clean
clean:
	$(RM) ncs_servd ncs_clientd *.o
